/* 
 * A664p7_udp.c -- Implements UDP support functions.
 *
 *
 *------------------------------------------------------------------------------
 *
 *                    ---   PROPRIETARY NOTICE   ---
 *
 *   The information contained herein is proprietary to Smiths Aerospace.
 *   and shall not be reproduced or disclosed in whole or in part or used
 *   for any design or manufacture except when such user possesses direct
 *   written authorization from Smiths Aerospace.
 *
 *   Copyright 2006, Smiths Aerospace.
 *
 *------------------------------------------------------------------------------
 *
 * modification history
 * --------------------
 * 30 mar 06	Huizenga	Initial revision.
 */

#include "pcap.h"

#ifndef WIN32
	#include <sys/socket.h>
	#include <netinet/in.h>
#else
	#include <winsock.h>
#endif
#include "A664p7_internal.h"

/* generate_udp_checksum: Sets the UDP checksum of "pack" to 0 (UDP checksums are not used in A664p7)
 *                        use_checksum should always be set to "0"
 */
void generate_udp_checksum(PACKET *pack, int use_checksum)
{
	mem_die(pack);
	pack->uh->check = 0;
	if(use_checksum)
		printf("ERROR: UDP Checksum Generation is not supported for A664p7 networks!");
}

void uh_to_net(UDP_HEADER *h)
{
	mem_die(h);
	h->length = htons(h->length);
}

void uh_from_net(UDP_HEADER *h)
{
	mem_die(h);
	h->length = ntohs(h->length);
}

void initialize_udp_header(UDP_HEADER *h)
{
	mem_die(h);
	h->length = sizeof(UDP_HEADER);
	uh_to_net(h);
}

void populate_udp_header(UDP_HEADER *h, unsigned short int s_port, unsigned short int d_port)
{
    mem_die(h);
	h->s_port = htons(s_port);
	h->d_port = htons(d_port);
}

